<script setup>
import { ref } from 'vue'

const isExpanded = ref(true)

// 取水数据
const waterData = ref({
  daily: '852369',
  monthly: '2341'
})

const togglePanel = () => {
  isExpanded.value = !isExpanded.value
}
</script>

<template>
  <div class="left-panel" :class="{ 'collapsed': !isExpanded }">
    <div class="toggle-btn" @click="togglePanel">
      <span class="arrow" :class="{ 'reversed': !isExpanded }">›</span>
    </div>
    <div class="panel-content" :class="{ 'hidden': !isExpanded }">
      <div class="data-card">
        <h3>取水统计</h3>
        <div class="data-list">
          <div class="data-item">
            <span class="label">当日取水量</span>
            <span class="value">{{ waterData.daily }}</span>
          </div>
          <div class="data-item">
            <span class="label">当月取水量</span>
            <span class="value">{{ waterData.monthly }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
@use '@/assets/styles/variables' as *;

.left-panel {
  position: relative;
  width: calc($sidebar-width * var(--scale-ratio));
  height: 96%;
  background-color: $bg-panel;
  padding: calc($padding-sm * var(--scale-ratio));
  border-radius: $border-radius;
  transition: all 0.3s ease;
  overflow: visible;

  &.collapsed {
    width: 24px !important;
    padding: 0;
    overflow: visible;
    transform: translateX(-100%);
  }

  .toggle-btn {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 40px;
    background-color: $bg-panel;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
  }

  .arrow {
    color: $text-color;
    font-size: 20px;
    transition: transform 0.3s ease;

    &.reversed {
      transform: rotate(180deg);
    }
  }
}

.panel-content {
  opacity: 1;
  transition: opacity 0.3s ease;

  &.hidden {
    opacity: 0;
  }

  .data-card {
    h3 {
      margin-bottom: $padding-sm;
      font-size: $font-size-xl;
    }

    .data-list {
      .data-item {
        display: flex;
        justify-content: space-between;
        margin-bottom: $padding-xs;

        .value {
          color: $info-color;
          font-size: $font-size-xl;
        }
      }
    }
  }
}
</style>
